/** 
Copyright (c) 2010, Sheikh Abdul Wahid Ahmed
Details @ http://extremecodeworld.codeplex.com/license
**/

using System;
using CodeGenerator.Definitions;
using System.Text;
using System.Reflection;
using EXtremecode.Logging;
using EXtremecode.Utils;
using CodeGenerator.Managers;

namespace CodeGenerator {
public class CodeGeneratingClass {
public static string BUZCustomCode(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//user code should be written under the following region, otherwise code will not be safe.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Custom Code [Code Generator]");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public const string VIEW_NAME=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(viewName);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "		public const string TABLE_NAME=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(tableName);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "		public const string DATATABLE_NAME=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityName);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "		private static Hashtable PopulateHashtableWithDefaultValues()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			Hashtable ht = new Hashtable();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			object val=null;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(string entityFieldKey in entity.Fields.Keys)
			{
				Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];


codeGeneratorVariable_DisplayCode.Append("		" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//**");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				if(cSharpKeywordDataType=="bool")
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			val=false;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
				else if(isRange)
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			val=");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(".MinValue;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
				else
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			val=null;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ht.Add(FieldNames.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append(",val);" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + codeGeneratorVariable_Prefix + "			return ht;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion Custom Code [Code Generator]");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZCustomCode()
{ return BUZCustomCode(string.Empty);}
public static string BUZDateRowMembers(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Members.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Construtors");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		internal ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow(DataRowBuilder rb) : base(rb){} " + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Properties");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string entityFieldKey in entity.Fields.Keys)
		{
			Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(" Value_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(isRange)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return (m_fields[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("].Value==DBNull.Value)?" + "\r\n" + codeGeneratorVariable_Prefix + "					 (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(")DEFAULT_VALUES[" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("]:" + "\r\n" + codeGeneratorVariable_Prefix + "					 (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(")this[" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
			else
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return (m_fields[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("].Value==DBNull.Value)?" + "\r\n" + codeGeneratorVariable_Prefix + "					 DEFAULT_VALUES[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("] as " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(":" + "\r\n" + codeGeneratorVariable_Prefix + "					 this[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("] as " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(isNative && !tokenEnabled && !autoIncreament )
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("]=value;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Relational Properties");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Children");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string relKey in  entity.Children.Keys)
		{   
			Entity.Relation relation = entity.Children[relKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


			Entity refEntity = relation.ReferencedEntity;

string refClassName=  StringProcessor.Class(refEntity.Name);
    string refCollectionName=  refClassName + "Collection";
	string refEntityName=  refEntity.Name;
	string refEntityCaption = StringProcessor.Caption(refEntity.Name);
	string refEntityVariable = StringProcessor.Variable(refEntity.Name);
	string refTableName=refEntity.TableName; 
	string refViewName=refEntity.ViewName;
	string refKeySignature=refEntity.KeySignature;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refEntityName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("DataRow[] Children_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ((");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refCollectionName);

codeGeneratorVariable_DisplayCode.Append("DataRow[])(base.GetChildRows(this.Table.ChildRelations[\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(childRelationName);

codeGeneratorVariable_DisplayCode.Append("\"])));" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Parents");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string relKey in  entity.Parents.Keys)
		{   
			Entity.Relation relation = entity.Parents[relKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


			Entity refEntity = relation.ReferencedEntity;

string refClassName=  StringProcessor.Class(refEntity.Name);
    string refCollectionName=  refClassName + "Collection";
	string refEntityName=  refEntity.Name;
	string refEntityCaption = StringProcessor.Caption(refEntity.Name);
	string refEntityVariable = StringProcessor.Variable(refEntity.Name);
	string refTableName=refEntity.TableName; 
	string refViewName=refEntity.ViewName;
	string refKeySignature=refEntity.KeySignature;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refEntityName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("DataRow Parent_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ((");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refCollectionName);

codeGeneratorVariable_DisplayCode.Append("DataRow)(base.GetParentRow(this.Table.ParentRelations[\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationName);

codeGeneratorVariable_DisplayCode.Append("\"])));" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                this.SetParentRow(value, this.Table.ParentRelations[\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationName);

codeGeneratorVariable_DisplayCode.Append("\"]);" + "\r\n" + codeGeneratorVariable_Prefix + "            }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDateRowMembers()
{ return BUZDateRowMembers(string.Empty);}
public static string BUZDataSetWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


		codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "namespace ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append(".BusinessObjects" + "\r\n" + codeGeneratorVariable_Prefix + "{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public class ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(":BusinessObject" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(BUZStatics() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZMembers() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZStaticMethods() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZCustomCode() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZDataTableRelatedMethods() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDataSetWholeClass()
{ return BUZDataSetWholeClass(string.Empty);}
public static string EntityFieldIncludes(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 

	/*string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];*/
 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string EntityFieldIncludes()
{ return EntityFieldIncludes(string.Empty);}
public static string BUZDataSetStaticMetods(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Static Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		private static void CreateDataSet(DataSet ds)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ArrayList alParentColumns=new ArrayList();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ArrayList alChildColumns=new ArrayList();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			DataTable dtParent,dtChild;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			#region Adding Tables to DataSet ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			<xsl:for-each select=\"ent:entity\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ds.Tables.Add(new <xsl:value-of select=\"@className\"/>DataTable());");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			</xsl:for-each>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			#region Adding Relations to DataSet ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			<xsl:for-each select=\"ent:entity[ent:children/ent:entityReference]\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			#region Relations of [\"<xsl:value-of select=\"@name\"/>\"]");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			dtParent=ds.Tables[\"<xsl:value-of select=\"@name\"/>\"];");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			<xsl:for-each select=\"ent:children/ent:entityReference\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			dtChild=ds.Tables[\"<xsl:value-of select=\"@name\"/>\"];");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			<xsl:for-each select=\"ent:relationalFields\">");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			<xsl:sort select=\"@nativeField\" />");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			alParentColumns.Add(dtParent.Columns[\"<xsl:value-of select=\"@nativeField\"/>\"]);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			alChildColumns.Add(dtChild.Columns[\"<xsl:value-of select=\"@referenceField\"/>\"]);</xsl:for-each>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ds.Relations.Add(\"<xsl:value-of select=\"@relationName\"/>\",(DataColumn[])alParentColumns.ToArray(alParentColumns[0].GetType()),(DataColumn[])alChildColumns.ToArray(alChildColumns[0].GetType()));");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			alChildColumns.Clear();alParentColumns.Clear();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			</xsl:for-each>");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "        #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDataSetStaticMetods()
{ return BUZDataSetStaticMetods(string.Empty);}
public static string BUZDateTableMembers(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Members.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Construtors");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable():base(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".DATATABLE_NAME){DefineDataTable(this);}" + "\r\n" + codeGeneratorVariable_Prefix + "		internal ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable(DataTable table) : " + "\r\n" + codeGeneratorVariable_Prefix + "                base(table.TableName) {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            if ((table.CaseSensitive != table.DataSet.CaseSensitive)) {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                this.CaseSensitive = table.CaseSensitive;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                this.Locale = table.Locale;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            if ((table.Namespace != table.DataSet.Namespace)) {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                this.Namespace = table.Namespace;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            this.Prefix = table.Prefix;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            this.MinimumCapacity = table.MinimumCapacity;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            this.DisplayExpression = table.DisplayExpression;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow New" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow()" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow)this.NewRow();" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		if(keySignature != string.Empty)
		{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow Get" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("ByKey(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(keySignature);

codeGeneratorVariable_DisplayCode.Append(")" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ArrayList al=new ArrayList();");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" col = " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(".NewInstance;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(Entity.Field entityField in entity.PrimaryKey)
			{   

string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			al.Add(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityVariable);

codeGeneratorVariable_DisplayCode.Append(");" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return this.Rows.Find(al.ToArray()) as ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow;" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region IEnumerable Implementation");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public System.Collections.IEnumerator GetEnumerator()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            return this.Rows.GetEnumerator();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Overridden Members");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override System.Type GetRowType() ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return typeof(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow);" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override DataRow NewRowFromBuilder(DataRowBuilder builder) ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow(builder);" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Properties");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow this[int index]" + "\r\n" + codeGeneratorVariable_Prefix + "        {");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow)this.Rows[index];" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        }");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "        #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDateTableMembers()
{ return BUZDateTableMembers(string.Empty);}
public static string BUZColCustomCode(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//user code should be written under the following region, otherwise code will not be safe.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Custom Code [Code Generator]");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//Connection Id");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		private static string s_connectionId=\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion Custom Code [Code Generator]");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZColCustomCode()
{ return BUZColCustomCode(string.Empty);}
public static string BUZDataTableStaticMethods(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Static Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		private static void DefineDataTable(DataTable dt)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			DataColumn dc=null;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ArrayList alPK=new ArrayList();");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string entityFieldKey in entity.Fields.Keys)
		{
			Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];


codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			/*** ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("***/ " + "\r\n" + codeGeneratorVariable_Prefix + "			dc=dt.Columns.Add(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("," + "\r\n" + codeGeneratorVariable_Prefix + "				typeof(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append("));" + "\r\n" + codeGeneratorVariable_Prefix + "			dc.Unique=");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(isUnique);

codeGeneratorVariable_DisplayCode.Append(";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(autoIncreament)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//value is computed by database management system.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			dc.ReadOnly=true;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			dc.AutoIncrement=true;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			dc.AutoIncrementSeed=-10;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			dc.AutoIncrementStep=-1;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
			
		}
		if(entity.PrimaryKey.Length>0)
		{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			/***PRIMARY KEY***/");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			DataColumn[] pk=new DataColumn[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entity.PrimaryKey.Length);

codeGeneratorVariable_DisplayCode.Append("];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			for(int i=0; i<entity.PrimaryKey.Length;  i++)
			{
				Entity.Field entityField = entity.PrimaryKey[i];

string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];


codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + codeGeneratorVariable_Prefix + "			pk[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(i);

codeGeneratorVariable_DisplayCode.Append("]=dt.Columns[" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			dt.PrimaryKey=pk;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDataTableStaticMethods()
{ return BUZDataTableStaticMethods(string.Empty);}
public static string BUZWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


		codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "namespace ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append(".BusinessObjects" + "\r\n" + codeGeneratorVariable_Prefix + "{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public class ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(":BusinessObject" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(BUZStatics() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZMembers() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZStaticMethods() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZCustomCode() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZDataTableRelatedMethods() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZWholeClass()
{ return BUZWholeClass(string.Empty);}
public static string BUZDataTableWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


		codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "namespace ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append(".BusinessObjects" + "\r\n" + codeGeneratorVariable_Prefix + "{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public class ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable:DataTable,System.Collections.IEnumerable" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(BUZDateTableMembers() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZDataTableStaticMethods() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public class ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow:DataRow" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(BUZDateRowMembers() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDataTableWholeClass()
{ return BUZDataTableWholeClass(string.Empty);}
public static string RelationIncludes(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 

	/*string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;

	*/
 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string RelationIncludes()
{ return RelationIncludes(string.Empty);}
public static string GeneralUsing(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "/** 
Copyright (c) 2010, Sheikh Abdul Wahid Ahmed
Details @ http://extremecodeworld.codeplex.com/license
**/

using System;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.BusinessLayer;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.XtreamAccessLayer;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.Util; ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Data;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Collections;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using System.Text;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "using EXtremecode.Configurations;");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string GeneralUsing()
{ return GeneralUsing(string.Empty);}
public static string BUZColWholeClass(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


		codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "namespace ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(accessorName);

codeGeneratorVariable_DisplayCode.Append(".BusinessObjects" + "\r\n" + codeGeneratorVariable_Prefix + "{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public class ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(":BusinessObjectCollection" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//Thread based Singleton");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" Instance" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" coll=Misc.ThreadSpecifics[\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append("\"];" + "\r\n" + codeGeneratorVariable_Prefix + "				if(coll == null) ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					coll=NewInstance;	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return coll;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" NewInstance" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" instence;" + "\r\n" + codeGeneratorVariable_Prefix + "				if(s_connectionId!=\"\") ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    instence=new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append("(s_connectionId);" + "\r\n" + codeGeneratorVariable_Prefix + "				else");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					instence=new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append("();	" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return instence;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		 codeGeneratorVariable_DisplayCode.Append(BUZColMembers() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZColCustomCode() + Environment.NewLine);
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZColWholeClass()
{ return BUZColWholeClass(string.Empty);}
public static string BUZDataSetMembers(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "\r\n" + codeGeneratorVariable_Prefix + "        #region Members.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Constructors");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public BODataSet():base(\"BODataSet\"){CreateDataSet(this);}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected BODataSet(SerializationInfo info, StreamingContext context)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			string strSchema = ((string)(info.GetValue(\"XmlSchema\", typeof(string))));");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if ((strSchema != null))");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				DataSet ds = new DataSet();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				ds.ReadXmlSchema(new XmlTextReader(new System.IO.StringReader(strSchema)));");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				foreach(string key in RepositoryManager.Instance.Entities.Keys)
				{ 
					Entity entity = RepositoryManager.Instance.Entities[key];

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				if ((ds.Tables[\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityName);

codeGeneratorVariable_DisplayCode.Append("\"] != null))" + "\r\n" + codeGeneratorVariable_Prefix + "				{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "					this.Tables.Add(new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable(ds.Tables[\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityName);

codeGeneratorVariable_DisplayCode.Append("\"]));" + "\r\n" + codeGeneratorVariable_Prefix + "				}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this.DataSetName = ds.DataSetName;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this.Prefix = ds.Prefix;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this.Namespace = ds.Namespace;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this.Locale = ds.Locale;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this.CaseSensitive = ds.CaseSensitive;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this.EnforceConstraints = ds.EnforceConstraints;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				this.Merge(ds, false, System.Data.MissingSchemaAction.Add);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			this.GetSerializationData(info, context);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        //**Overridden Members");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Properties");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region DataTables");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string key in RepositoryManager.Instance.Entities.Keys)
		{ 
			Entity entity = RepositoryManager.Instance.Entities[key];

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable Table_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable)this.Tables[\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityName);

codeGeneratorVariable_DisplayCode.Append("\"];" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Relational Properties");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		#region DataRelations");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string key in RepositoryManager.Instance.Entities.Keys)
		{ 
			Entity entity = RepositoryManager.Instance.Entities[key];
			foreach(string relKey in  entity.Parents.Keys)
			{   
				Entity.Relation relation = entity.Parents[relKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public DataRelation Relation_");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationProperty);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return this.Relations[\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationName);

codeGeneratorVariable_DisplayCode.Append("\"];" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}  
		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		private static void CreateDataSet(DataSet ds)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			DataTable dtParent,dtChild;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//****** Adding Tables to DataSet ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string key in RepositoryManager.Instance.Entities.Keys)
		{ 
			Entity entity = RepositoryManager.Instance.Entities[key];

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ds.Tables.Add(new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable());" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "			//****** Adding Relations to DataSet ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string key in RepositoryManager.Instance.Entities.Keys)
		{ 
			Entity entity = RepositoryManager.Instance.Entities[key];

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


			foreach(string relKey in  entity.Children.Keys)
			{   
				Entity.Relation relation = entity.Children[relKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


				Entity refEntity = relation.ReferencedEntity;

string refClassName=  StringProcessor.Class(refEntity.Name);
    string refCollectionName=  refClassName + "Collection";
	string refEntityName=  refEntity.Name;
	string refEntityCaption = StringProcessor.Caption(refEntity.Name);
	string refEntityVariable = StringProcessor.Variable(refEntity.Name);
	string refTableName=refEntity.TableName; 
	string refViewName=refEntity.ViewName;
	string refKeySignature=refEntity.KeySignature;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//**[\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(childRelationName);

codeGeneratorVariable_DisplayCode.Append("\"]" + "\r\n" + codeGeneratorVariable_Prefix + "			DataColumn[] parentColumns=new DataColumn[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refKey.Length);

codeGeneratorVariable_DisplayCode.Append("];" + "\r\n" + codeGeneratorVariable_Prefix + "			DataColumn[] childColumns =new DataColumn[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refKey.Length);

codeGeneratorVariable_DisplayCode.Append("];;" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			dtParent=ds.Tables[\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityName);

codeGeneratorVariable_DisplayCode.Append("\"];" + "\r\n" + codeGeneratorVariable_Prefix + "			dtChild=ds.Tables[\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refEntityName);

codeGeneratorVariable_DisplayCode.Append("\"];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				for(int i=0; i<refKey.Length; i++)
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			parentColumns[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(i);

codeGeneratorVariable_DisplayCode.Append("] = dtParent.Columns[\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(nativeKey[i].Name);

codeGeneratorVariable_DisplayCode.Append("\"];" + "\r\n" + codeGeneratorVariable_Prefix + "			childColumns[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(i);

codeGeneratorVariable_DisplayCode.Append("] = dtChild.Columns[\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refKey[i].Name);

codeGeneratorVariable_DisplayCode.Append("\"];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ds.Relations.Add(\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(childRelationName);

codeGeneratorVariable_DisplayCode.Append("\",parentColumns,childColumns);" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}  
		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDataSetMembers()
{ return BUZDataSetMembers(string.Empty);}
public static string EntityIncludes(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 

	/*string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;*/
 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string EntityIncludes()
{ return EntityIncludes(string.Empty);}
public static string RefEntityFieldIncludes(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 

	/*string refEntityFieldCaption = StringProcessor.Caption(refEntityField.Name);
	string refProperty=  StringProcessor.Property(refEntityField.Name);
	string refEntityFieldName=  refEntityField.Name;
	string refEntityFieldConstant = StringProcessor.ConstantNStatic(refEntityField.Name);
	string refDbParameter = StringProcessor.DBParameter(refEntityField.Name);
	string refEntityFieldVariable = StringProcessor.Variable(refEntityField.Name);
	string refTokenId=refEntityField.TokenId;
	bool refAutoIncreament=refEntityField.AutoIncreament;
	bool refTokenEnabled=refEntityField.TokenEnabled;
	bool refIsNative=refEntityField.IsNative;
	bool refIsRange=refEntityField.IsRange;
	bool refIsKey=refEntityField.IsKey;
	bool refIsUnique=refEntityField.IsUnique; 
	string refCSharpKeywordDataType=FreeHash.CSharpType[refEntityField.DataType]; 
	string refDataType=refEntityField.DataType; 
	string refCSharpFrameworkDataType=FreeHash.CSharpSystemType[refEntityField.DataType];*/
 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string RefEntityFieldIncludes()
{ return RefEntityFieldIncludes(string.Empty);}
public static string BUZDataSetInnerClasses(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "\r\n" + codeGeneratorVariable_Prefix + "	#region Inner Classes");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public class TableNames");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string key in RepositoryManager.Instance.Entities.Keys)
		{ 
			Entity entity = RepositoryManager.Instance.Entities[key];

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public const string ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(" = \"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityName);

codeGeneratorVariable_DisplayCode.Append("\";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	public class RelationNames");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string key in RepositoryManager.Instance.Entities.Keys)
		{ 
			Entity entity = RepositoryManager.Instance.Entities[key];
			foreach(string relKey in  entity.Parents.Keys)
			{   
				Entity.Relation relation = entity.Parents[relKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public const string ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationProperty);

codeGeneratorVariable_DisplayCode.Append(" = \"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationName);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			} 
		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "	}	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "    #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDataSetInnerClasses()
{ return BUZDataSetInnerClasses(string.Empty);}
public static string TestingTable(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 

	Entity entity = 
		RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("			" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


	foreach(string entityFieldKey in entity.Fields.Keys)
	{
		Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];


codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);


	}
 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string TestingTable()
{ return TestingTable(string.Empty);}
public static string TestingOnce(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 

	foreach(string entityKey in RepositoryManager.Instance.Entities.Keys)
	{
		Entity entity=RepositoryManager.Instance.Entities[entityKey]; 

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("			" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string entityFieldKey in entity.Fields.Keys)
		{
			Entity.Field entityField = entity.Fields[entityFieldKey]; 

string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];


codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);


		}  		
	}
 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string TestingOnce()
{ return TestingOnce(string.Empty);}
public static string BUZMembers(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Members.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Construtors");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//For current row");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		internal ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("(FieldInfoCollection fields ,DataAccessor da):base(fields,da){}" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//For new row with default connection ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public  ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("():base(){}" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//For new row with given connection ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("(string strConnectionId):base(strConnectionId){}" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public void PopulateObject(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataRow dr)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			base.PopulateObject(dr);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Overridden Members");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override FieldInfoCollection GetFieldInfoCollection()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return FIELDS;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override BusinessObjectRelationCollection ChildRelations");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return CHILD_RELATIONS;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override BusinessObjectRelationCollection ParentRelations");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return PARENT_RELATIONS;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override string Table_Name");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return TABLE_NAME;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override string View_Name");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return VIEW_NAME;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override void PopulateWithCommandCreators(ref CommandCreatorHandler selectCmdCreator,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ref CommandCreatorHandler updateCmdCreator,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ref CommandCreatorHandler insertCmdCreator,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ref CommandCreatorHandler deleteCmdCreator)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//can be used later.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			selectCmdCreator = null; //new CommandCreatorHandler(Create_SelectIDbCommand);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			updateCmdCreator = null; //new CommandCreatorHandler(Create_UpdateIDbCommand);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			insertCmdCreator = null; //new CommandCreatorHandler(Create_InsertIDbCommand);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			deleteCmdCreator = null; //new CommandCreatorHandler(Create_DeleteIDbCommand);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Properties");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string entityFieldKey in entity.Fields.Keys)
		{
			Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(isRange)
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return (m_fields[FieldNames.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("].Value==DBNull.Value)?" + "\r\n" + codeGeneratorVariable_Prefix + "					 (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(")DEFAULT_VALUES[FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("]:" + "\r\n" + codeGeneratorVariable_Prefix + "					 (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(")m_fields[FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("].Value;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
			else
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return (m_fields[FieldNames.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("].Value==DBNull.Value)?" + "\r\n" + codeGeneratorVariable_Prefix + "					 DEFAULT_VALUES[FieldNames.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("] as " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(":" + "\r\n" + codeGeneratorVariable_Prefix + "					 m_fields[FieldNames.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("].Value as " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			if(isNative && !tokenEnabled && !autoIncreament )
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				m_fields[FieldNames.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("].Value=value;" + "\r\n" + codeGeneratorVariable_Prefix + "				m_daCommad[FieldNames.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("]=value;" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Relational Properties");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Children");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string relKey in  entity.Children.Keys)
		{   
			Entity.Relation relation = entity.Children[relKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


			Entity refEntity = relation.ReferencedEntity;

string refClassName=  StringProcessor.Class(refEntity.Name);
    string refCollectionName=  refClassName + "Collection";
	string refEntityName=  refEntity.Name;
	string refEntityCaption = StringProcessor.Caption(refEntity.Name);
	string refEntityVariable = StringProcessor.Variable(refEntity.Name);
	string refTableName=refEntity.TableName; 
	string refViewName=refEntity.ViewName;
	string refKeySignature=refEntity.KeySignature;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refEntityName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refCollectionName);

codeGeneratorVariable_DisplayCode.Append(" Children_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refCollectionName);

codeGeneratorVariable_DisplayCode.Append(" colRef=" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refCollectionName);

codeGeneratorVariable_DisplayCode.Append(".Instance;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			for(int i=0; i<relation.NativeKey.Length;  i++)
			{
				Entity.Field entityField = relation.NativeKey[i];
				Entity.Field refEntityField = relation.ReferencedKey[i];

string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];



string refEntityFieldCaption = StringProcessor.Caption(refEntityField.Name);
	string refProperty=  StringProcessor.Property(refEntityField.Name);
	string refEntityFieldName=  refEntityField.Name;
	string refEntityFieldConstant = StringProcessor.ConstantNStatic(refEntityField.Name);
	string refDbParameter = StringProcessor.DBParameter(refEntityField.Name);
	string refEntityFieldVariable = StringProcessor.Variable(refEntityField.Name);
	string refTokenId=refEntityField.TokenId;
	bool refAutoIncreament=refEntityField.AutoIncreament;
	bool refTokenEnabled=refEntityField.TokenEnabled;
	bool refIsNative=refEntityField.IsNative;
	bool refIsRange=refEntityField.IsRange;
	bool refIsKey=refEntityField.IsKey;
	bool refIsUnique=refEntityField.IsUnique; 
	string refCSharpKeywordDataType=FreeHash.CSharpType[refEntityField.DataType]; 
	string refDataType=refEntityField.DataType; 
	string refCSharpFrameworkDataType=FreeHash.CSharpSystemType[refEntityField.DataType];


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				colRef.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refProperty);

codeGeneratorVariable_DisplayCode.Append("=" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return colRef;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "   		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append(" CreateNewChild_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("()" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append(" boNew=" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append(".CreateNewBusinessObject();" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			for(int i=0; i<relation.NativeKey.Length;  i++)
			{
				Entity.Field entityField = relation.NativeKey[i];
				Entity.Field refEntityField = relation.ReferencedKey[i];

string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];



string refEntityFieldCaption = StringProcessor.Caption(refEntityField.Name);
	string refProperty=  StringProcessor.Property(refEntityField.Name);
	string refEntityFieldName=  refEntityField.Name;
	string refEntityFieldConstant = StringProcessor.ConstantNStatic(refEntityField.Name);
	string refDbParameter = StringProcessor.DBParameter(refEntityField.Name);
	string refEntityFieldVariable = StringProcessor.Variable(refEntityField.Name);
	string refTokenId=refEntityField.TokenId;
	bool refAutoIncreament=refEntityField.AutoIncreament;
	bool refTokenEnabled=refEntityField.TokenEnabled;
	bool refIsNative=refEntityField.IsNative;
	bool refIsRange=refEntityField.IsRange;
	bool refIsKey=refEntityField.IsKey;
	bool refIsUnique=refEntityField.IsUnique; 
	string refCSharpKeywordDataType=FreeHash.CSharpType[refEntityField.DataType]; 
	string refDataType=refEntityField.DataType; 
	string refCSharpFrameworkDataType=FreeHash.CSharpSystemType[refEntityField.DataType];


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			boNew.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refProperty);

codeGeneratorVariable_DisplayCode.Append("=" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return boNew;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#region Parents");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string relKey in  entity.Parents.Keys)
		{   
			Entity.Relation relation = entity.Parents[relKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


			Entity refEntity = relation.ReferencedEntity;

string refClassName=  StringProcessor.Class(refEntity.Name);
    string refCollectionName=  refClassName + "Collection";
	string refEntityName=  refEntity.Name;
	string refEntityCaption = StringProcessor.Caption(refEntity.Name);
	string refEntityVariable = StringProcessor.Variable(refEntity.Name);
	string refTableName=refEntity.TableName; 
	string refViewName=refEntity.ViewName;
	string refKeySignature=refEntity.KeySignature;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refEntityName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append(" Parent_" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refClassName);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refCollectionName);

codeGeneratorVariable_DisplayCode.Append(" colRef=" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refCollectionName);

codeGeneratorVariable_DisplayCode.Append(".Instance;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			for(int i=0; i<relation.NativeKey.Length;  i++)
			{
				Entity.Field entityField = relation.NativeKey[i];
				Entity.Field refEntityField = relation.ReferencedKey[i];

string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];



string refEntityFieldCaption = StringProcessor.Caption(refEntityField.Name);
	string refProperty=  StringProcessor.Property(refEntityField.Name);
	string refEntityFieldName=  refEntityField.Name;
	string refEntityFieldConstant = StringProcessor.ConstantNStatic(refEntityField.Name);
	string refDbParameter = StringProcessor.DBParameter(refEntityField.Name);
	string refEntityFieldVariable = StringProcessor.Variable(refEntityField.Name);
	string refTokenId=refEntityField.TokenId;
	bool refAutoIncreament=refEntityField.AutoIncreament;
	bool refTokenEnabled=refEntityField.TokenEnabled;
	bool refIsNative=refEntityField.IsNative;
	bool refIsRange=refEntityField.IsRange;
	bool refIsKey=refEntityField.IsKey;
	bool refIsUnique=refEntityField.IsUnique; 
	string refCSharpKeywordDataType=FreeHash.CSharpType[refEntityField.DataType]; 
	string refDataType=refEntityField.DataType; 
	string refCSharpFrameworkDataType=FreeHash.CSharpSystemType[refEntityField.DataType];


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				colRef.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(refProperty);

codeGeneratorVariable_DisplayCode.Append("=" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append(";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return colRef.BusinessObject;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZMembers()
{ return BUZMembers(string.Empty);}
public static string RefEntityIncludes(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 

	/*string refClassName=  StringProcessor.Class(refEntity.Name);
    string refCollectionName=  refClassName + "Collection";
	string refEntityName=  refEntity.Name;
	string refEntityCaption = StringProcessor.Caption(refEntity.Name);
	string refEntityVariable = StringProcessor.Variable(refEntity.Name);
	string refTableName=refEntity.TableName; 
	string refViewName=refEntity.ViewName;
	string refKeySignature=refEntity.KeySignature;*/
 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string RefEntityIncludes()
{ return RefEntityIncludes(string.Empty);}
public static string BUZStatics(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Bussiness Object Statics");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		internal readonly static FieldInfoCollection FIELDS=CreateFieldInfoCollection();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		internal readonly static BusinessObjectRelationCollection CHILD_RELATIONS=CreateChildRelations();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		internal readonly static BusinessObjectRelationCollection PARENT_RELATIONS=CreateParentRelations();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		private readonly static Hashtable DEFAULT_VALUES=PopulateHashtableWithDefaultValues();	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public class FieldNames");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{	");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


        foreach(string entityFieldKey in entity.Fields.Keys)
        {
            Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "            public const string ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append(" = \"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldName);

codeGeneratorVariable_DisplayCode.Append("\";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


        }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" Collection" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(".Instance;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" NewCollection" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(".NewInstance;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZStatics()
{ return BUZStatics(string.Empty);}
public static string BUZColMembers(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Members.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Construtors");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//for Default Connection");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append("():base(){}		" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//for Given Connection ");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append("(string strConnectionId):base(strConnectionId){}		" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public  ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(" CreateNewBusinessObject()" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("(m_da.Name);" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable FillDataTable(DataSet ds)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable)base.FillDataTable(ds);" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable FillDataTable()" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable)base.FillDataTable();" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "		//**Overridden Members");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override BusinessObject CreateBusinessObject(FieldInfoCollection fields)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("(fields,m_da);" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override FieldInfoCollection GetFieldInfoCollection()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FIELDS;" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public override BusinessObjectRelationCollection ChildRelations");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".CHILD_RELATIONS;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public override BusinessObjectRelationCollection ParentRelations");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".PARENT_RELATIONS;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public override string View_Name");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".VIEW_NAME;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public override string Table_Name");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".TABLE_NAME;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public override string DataTable_Name");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".DATATABLE_NAME;" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected override DataTable CreateDataTable()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return new ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable();" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n\r\n" + codeGeneratorVariable_Prefix + "		protected override void PopulateWithCommandCreators(ref CommandCreatorHandler selectCmdCreator,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ref CommandCreatorHandler updateCmdCreator,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ref CommandCreatorHandler insertCmdCreator,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			ref CommandCreatorHandler deleteCmdCreator)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			//can be used later.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			selectCmdCreator = null; //new CommandCreatorHandler(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".Create_SelectIDbCommand);" + "\r\n" + codeGeneratorVariable_Prefix + "			updateCmdCreator = null; //new CommandCreatorHandler(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".Create_UpdateIDbCommand);" + "\r\n" + codeGeneratorVariable_Prefix + "			insertCmdCreator = null; //new CommandCreatorHandler(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".Create_InsertIDbCommand);" + "\r\n" + codeGeneratorVariable_Prefix + "			deleteCmdCreator = null; //new CommandCreatorHandler(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".Create_DeleteIDbCommand);" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		//**Properties");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public  ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(" BusinessObject" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			get");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				return base.GetBusinessObject() as ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("; " + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		foreach(string entityFieldKey in entity.Fields.Keys)
		{
			Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];


codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			//binary fields cant be included in where clause. 
			if(dataType!="shortbinary" && dataType!="binary")
			{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				m_selectDACommad[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("]=value; " + "\r\n" + codeGeneratorVariable_Prefix + "				m_adapter.SelectCommand[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("]=value; " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				if(isNative)
				{
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + codeGeneratorVariable_Prefix + "				m_deleteDACommand[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("]=value;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				m_alDirtyParams.Add(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append(");				" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				if(isRange)
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_From" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				m_selectDACommad[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("+Constants.ColumnSuffix.FROM]=value; " + "\r\n" + codeGeneratorVariable_Prefix + "				m_adapter.SelectCommand[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("+Constants.ColumnSuffix.FROM]=value; " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


					if(isNative)
					{
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + codeGeneratorVariable_Prefix + "				m_deleteDACommand[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("+Constants.ColumnSuffix.FROM]=value;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


					}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				m_alDirtyParams.Add(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("+Constants.ColumnSuffix.FROM);				" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(cSharpKeywordDataType);

codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("_To" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			set");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				m_selectDACommad[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("+Constants.ColumnSuffix.TO]=value; " + "\r\n" + codeGeneratorVariable_Prefix + "				m_adapter.SelectCommand[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("+Constants.ColumnSuffix.TO]=value; " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


					if(isNative)
					{
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + codeGeneratorVariable_Prefix + "				m_deleteDACommand[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("+Constants.ColumnSuffix.TO]=value;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


					}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				m_alDirtyParams.Add(");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(".FieldNames." + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("+Constants.ColumnSuffix.TO);				" + "\r\n" + codeGeneratorVariable_Prefix + "			}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				}
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		}
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		#endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZColMembers()
{ return BUZColMembers(string.Empty);}
public static string BUZStaticMethods(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region Static Methods");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected static FieldInfoCollection  CreateFieldInfoCollection()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if(FIELDS !=null) return FIELDS;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			FieldInfoCollection fields=new FieldInfoCollection();");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(string entityFieldKey in entity.Fields.Keys)
			{
				Entity.Field entityField = entity.Fields[entityFieldKey];

string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];


codeGeneratorVariable_DisplayCode.Append("		" + "\r\n" + codeGeneratorVariable_Prefix + "				fields.Add(FieldNames.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append("," + "\r\n" + codeGeneratorVariable_Prefix + "					new FieldInfo(FieldNames.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldConstant);

codeGeneratorVariable_DisplayCode.Append(",\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(dataType);

codeGeneratorVariable_DisplayCode.Append("\"," + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(isKey);

codeGeneratorVariable_DisplayCode.Append("," + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(isUnique);

codeGeneratorVariable_DisplayCode.Append(",\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(tokenId);

codeGeneratorVariable_DisplayCode.Append("\"," + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(autoIncreament);

codeGeneratorVariable_DisplayCode.Append("," + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(isNative);

codeGeneratorVariable_DisplayCode.Append("," + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(isRange);

codeGeneratorVariable_DisplayCode.Append("));" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("	" + "\r\n" + codeGeneratorVariable_Prefix + "			return fields;	");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected static BusinessObjectRelationCollection CreateChildRelations()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if(CHILD_RELATIONS != null) return CHILD_RELATIONS;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			BusinessObjectRelationCollection relations=new BusinessObjectRelationCollection();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(string childrenKey in  entity.Children.Keys)
			{   
				Entity.Relation relation = entity.Children[childrenKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				//Relation [");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(childRelationName);

codeGeneratorVariable_DisplayCode.Append("]" + "\r\n" + codeGeneratorVariable_Prefix + "			    string[] nativeFields=new string[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.NativeKey.Length);

codeGeneratorVariable_DisplayCode.Append("];" + "\r\n" + codeGeneratorVariable_Prefix + "                string[] referencedFields=new string[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.NativeKey.Length);

codeGeneratorVariable_DisplayCode.Append("];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				for(int i=0; i<relation.NativeKey.Length;  i++)
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                nativeFields[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(i);

codeGeneratorVariable_DisplayCode.Append("]=\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.NativeKey[i].Name);

codeGeneratorVariable_DisplayCode.Append("\";referencedFields[" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(i);

codeGeneratorVariable_DisplayCode.Append("]=\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.ReferencedKey[i].Name);

codeGeneratorVariable_DisplayCode.Append("\";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			    }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "                relations.Add(\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.ReferencedEntityName);

codeGeneratorVariable_DisplayCode.Append("\"," + "\r\n" + codeGeneratorVariable_Prefix + "                    new BusinessObjectRelation(\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(childRelationName);

codeGeneratorVariable_DisplayCode.Append("\"," + "\r\n" + codeGeneratorVariable_Prefix + "                        DATATABLE_NAME,nativeFields,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        \"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.ReferencedEntityName);

codeGeneratorVariable_DisplayCode.Append("\",referencedFields));" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return relations;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		protected static BusinessObjectRelationCollection CreateParentRelations()");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			if(PARENT_RELATIONS != null) return PARENT_RELATIONS;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			BusinessObjectRelationCollection relations=new BusinessObjectRelationCollection();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(string parentsKey in  entity.Parents.Keys)
			{   
				Entity.Relation relation = entity.Parents[parentsKey];

string parentRelationName =  StringProcessor.RelationName(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationName =  StringProcessor.RelationName(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	string parentRelationProperty =  StringProcessor.RelationProperty(relation.ReferencedEntity.Name,relation.NativeEntity.Name);
	string childRelationProperty =  StringProcessor.RelationProperty(relation.NativeEntity.Name,relation.ReferencedEntity.Name);
	Entity.Field[] nativeKey =relation.NativeKey;
	Entity.Field[] refKey =relation.ReferencedKey;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "				//Relation [");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationName);

codeGeneratorVariable_DisplayCode.Append("]" + "\r\n" + codeGeneratorVariable_Prefix + "			    string[] nativeFields=new string[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.NativeKey.Length);

codeGeneratorVariable_DisplayCode.Append("];" + "\r\n" + codeGeneratorVariable_Prefix + "                string[] referencedFields=new string[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.NativeKey.Length);

codeGeneratorVariable_DisplayCode.Append("];" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


				for(int i=0; i<relation.NativeKey.Length;  i++)
				{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                    nativeFields[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(i);

codeGeneratorVariable_DisplayCode.Append("]=\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.NativeKey[i].Name);

codeGeneratorVariable_DisplayCode.Append("\";" + "\r\n" + codeGeneratorVariable_Prefix + "                    referencedFields[");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(i);

codeGeneratorVariable_DisplayCode.Append("]=\"" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.ReferencedKey[i].Name);

codeGeneratorVariable_DisplayCode.Append("\";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			    }
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                relations.Add(\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.ReferencedEntityName);

codeGeneratorVariable_DisplayCode.Append("\"," + "\r\n" + codeGeneratorVariable_Prefix + "                    new BusinessObjectRelation(\"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(parentRelationName);

codeGeneratorVariable_DisplayCode.Append("\"," + "\r\n" + codeGeneratorVariable_Prefix + "                        DATATABLE_NAME,nativeFields,");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "                        \"");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(relation.ReferencedEntityName);

codeGeneratorVariable_DisplayCode.Append("\",referencedFields));" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return relations;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		if(keySignature != string.Empty)
		{
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(" Get" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("ByKey(" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(keySignature);

codeGeneratorVariable_DisplayCode.Append(")" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(" col = " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(".NewInstance;" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			foreach(Entity.Field entityField in entity.PrimaryKey)
			{   

string entityFieldCaption = StringProcessor.Caption(entityField.Name);
	string property=  StringProcessor.Property(entityField.Name);
	string entityFieldName=  entityField.Name;
	string entityFieldConstant = StringProcessor.ConstantNStatic(entityField.Name);
	string dbParameter = StringProcessor.DBParameter(entityField.Name);
	string entityFieldVariable = StringProcessor.Variable(entityField.Name);
	string tokenId=entityField.TokenId;
	bool autoIncreament=entityField.AutoIncreament;
	bool tokenEnabled=entityField.TokenEnabled;
	bool isNative=entityField.IsNative;
	bool isRange=entityField.IsRange;
	bool isKey=entityField.IsKey;
	bool isUnique=entityField.IsUnique; 
	string cSharpKeywordDataType=FreeHash.CSharpType[entityField.DataType]; 
	string dataType=entityField.DataType; 
	string cSharpFrameworkDataType=FreeHash.CSharpSystemType[entityField.DataType];


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			col.");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(property);

codeGeneratorVariable_DisplayCode.Append("=" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(entityFieldVariable);

codeGeneratorVariable_DisplayCode.Append(";" + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return col.BusinessObject;");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


			}
codeGeneratorVariable_DisplayCode.Append("" + "\r\n\r\n" + codeGeneratorVariable_Prefix + "		public static  ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append(" CreateNewBusinessObject()" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(collectionName);

codeGeneratorVariable_DisplayCode.Append(".Instance.CreateNewBusinessObject(); " + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZStaticMethods()
{ return BUZStaticMethods(string.Empty);}
public static string BUZDataTableRelatedMethods(string codeGeneratorVariable_Prefix)
{ StringBuilder codeGeneratorVariable_DisplayCode=new StringBuilder();try { 
codeGeneratorVariable_DisplayCode.Append(" " + "" + "");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");


		Entity entity = RepositoryManager.Instance.ActiveEntity;

string className=  StringProcessor.Class(entity.Name);
    string collectionName=  className + "Collection";
	string entityName=  entity.Name;
	string entityCaption = StringProcessor.Caption(entity.Name);
	string entityVariable = StringProcessor.Variable(entity.Name);
	string tableName=entity.TableName; 
	string viewName=entity.ViewName;
	string keySignature=entity.KeySignature;
	string accessorName=entity.AccessorName;


codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #region DataTable Related Methods.");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable GetDataTable(DataSet ds)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return (");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable)ds.Tables[DATATABLE_NAME];" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable FillDataTable(DataSet ds)" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return Collection.FillDataTable(ds);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static ");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

codeGeneratorVariable_DisplayCode.Append(className);

codeGeneratorVariable_DisplayCode.Append("DataTable FillDataTable()" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			return Collection.FillDataTable();");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static void UpdateDataTable(DataTable dt)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			Collection.UpdateDataTable(dt,false);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		public static void UpdateDataTable(DataTable dt,bool bTransationBased)");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		{");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "			Collection.UpdateDataTable(dt,bTransationBased);");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "		}");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + "");
codeGeneratorVariable_DisplayCode.Append("" + "\r\n" + codeGeneratorVariable_Prefix + "        #endregion");
codeGeneratorVariable_DisplayCode.Append("" + "" + "");

 } catch(Exception ex) { throw Logger.Write(ex); }
 return codeGeneratorVariable_DisplayCode.ToString();
}
public static string BUZDataTableRelatedMethods()
{ return BUZDataTableRelatedMethods(string.Empty);}
}}
